/*
 * @Author: Joel
 * @Date: 2025-04-23 15:01:51
 * @LastEditors: Joel
 * @LastEditTime: 2025-04-23 17:55:56
 * @FilePath: /gd32f303cct6/usr/cdc_acm/inc/usbd_conf.h
 * @Description: 
 * Copyright (C) 2025 YiJiaLink, All Rights Reserved. 
 * 2025-04-23 15:01:51
 */

#ifndef USBD_CONF_H
#define USBD_CONF_H

#include "gd32f30x.h"

#define USBD_CFG_MAX_NUM                   1U
#define USBD_ITF_MAX_NUM                   1U

#define CDC_COM_INTERFACE                  0U

/* define if low power mode is enabled; it allows entering the device into DEEP_SLEEP mode
   following USB suspend event and wakes up after the USB wakeup event is received. */
//#define USBD_LOWPWR_MODE_ENABLE

/* USB feature -- Self Powered */
/* #define USBD_SELF_POWERED */

/* endpoint count used by the CDC ACM device */
#define CDC_CMD_EP                         EP_IN(2U)
#define CDC_IN_EP                          EP_IN(1U)
#define CDC_OUT_EP                         EP_OUT(3U)

/* endpoint0, Rx/Tx buffers address offset */
#define EP0_RX_ADDR                        (0x40U)
#define EP0_TX_ADDR                        (0x80U)

/* CDC data Tx buffer address offset */
#define BULK_TX_ADDR                       (0x140U)

/* CDC data Rx buffer address offset */
#define BULK_RX_ADDR                       (0x100U)

/* CDC command Tx buffer address offset */
#define INT_TX_ADDR                        (0xC0U)

#define CDC_ACM_CMD_PACKET_SIZE            8U
#define CDC_ACM_DATA_PACKET_SIZE           64U

/* endpoint count used by the CDC ACM device */
#define EP_COUNT                           (4U)

#define USB_STRING_COUNT                   4U

/* base address offset of the allocation buffer, used for buffer descriptor table and packet memory */
#define BTABLE_OFFSET                      (0x0000U)

#define USB_PULLUP                         GPIOA
#define USB_PULLUP_PIN                     GPIO_PIN_12
#define RCU_PULLUP                         RCU_GPIOA

#endif /* USBD_CONF_H */
